package com.example.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 	注解扫描的方式
 * 	继承HttpServlet类
 * @author yzl
 *
 */
@WebServlet(urlPatterns="/hello.do",description="注解扫描")
public class AnnotationScanningServlet1 extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("注解扫描---------->doGet()方法被执行");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("注解扫描---------->doPost()方法被执行");
		resp.setContentType("text/html");
		String id = req.getParameter("id");
		if(id != null && !id.equals("")){
			resp.getWriter().append("注解扫描----------> doPost() id= "+id);
			return;
		}
		resp.getWriter().append("注解扫描----------> doPost()");
	}

	@Override
	public void init() throws ServletException {
		System.out.println("注解扫描初始化方法被执行！");
		super.init();
	}

}
